package com.customize.tool.component;

import com.customize.tool.properties.UserProperties;
import com.customize.tool.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @Author: suichen
 * @Date: 2022-02-25 0:10
 * @Description: 自动配置类
 */
@Configuration
@EnableConfigurationProperties(UserProperties.class)
public class UserAutoConfiguration {

    @Resource
    private UserProperties userProperties;

    /**
     * 使用@Bean注解将UserService注入到Spring容器中
     * @return
     */
    @Bean
    public UserService userService(){
        return new UserService(userProperties);
    }


}
